import request from '@/utils/request';
import type { BaseBeanModel, ResponsePageData, ResponseBaseData, QueryParamModel } from '@/api/model/baseModel';
import type { downloadParam } from '@/utils/download-util';
import { downloadSysFile } from '@/utils/download-util';
export const basePath = '/tlk/back/dataentity';
/** DataEntity */
export interface DataEntityDto extends BaseBeanModel {
  /** 编码 */
  code?: string;
  /** 中文名称 */
  cnName?: string;
  /** 描述 */
  desc?: string;
  /** 英文名称 */
  enName?: string;
}

/** 获取分页数据 */
export function listDataEntityByPage(param: QueryParamModel): Promise<ResponsePageData<DataEntityDto>> {
  return request.post(`${basePath}/find-list-by-page/v1`, param);
}

/** 根据id加载数据 */
export function getDataEntity(id: string): Promise<ResponseBaseData<DataEntityDto>> {
  return request.get(`${basePath}/get/${id}/v1`);
}

/** 保存表单数据 */
export function saveDataEntity(form: DataEntityDto): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/save/v1`, form);
}

/** 根据id集合删除数据 */
export function delDataEntity(ids: [string]): Promise<ResponseBaseData<any>> {
  return request.delete(`${basePath}/delete-by-ids/v1`, { data: ids });
}

/** 导出Excel */
export function exportExcel(param: any) {
  const download = {
    url: `${basePath}/export-data/v1`,
    data: param,
    method: 'post'
  } as downloadParam;
  return downloadSysFile(download);
}
